package tv.youxing.android;

import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import tv.youxing.android.ui.BaseActivity;
import tv.youxing.android.ui.CheckAPKInfoActivity;


/**
 * 关于我们
 */
public class AboutUsActivity extends BaseActivity {

    @BindView(R.id.versionchecking)
    RelativeLayout versionchecking;
    @BindView(R.id.call)
    RelativeLayout call;
    @BindView(R.id.edition_des)
    TextView edition_des;//版本介绍

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about_us);
        ButterKnife.bind(this);
    }

    @OnClick({R.id.versionchecking,R.id.call})
    public void click(View view) {
        switch (view.getId()) {
            //检测检查
            case R.id.versionchecking:
                startActivity(new Intent(AboutUsActivity.this, CheckAPKInfoActivity.class));
                break;
            //联系我们
            case R.id.call:
                call_Show();
                break;
        }
    }

    //联系我们的dialog
    void call_Show() {
        android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(this);
        builder.setTitle("是否拨打客服电话");
        builder.setMessage("0592-5929181");
        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {

            }
        });
        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                call("0592-5929181");
            }
        });
        builder.show();
    }

    /**
     * 调用拨号界面
     * @param phone 电话号码
     */
    private void call(String phone) {
        Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"+phone));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
    }
}
